DEFINE VARIABLE tax_rate AS DECIMAL.
DEFINE VARIABLE vno  AS INTEGER.
DEFINE VARIABLE vend AS CHARACTER.
DEFINE VARIABLE curr AS CHARACTER.

FOR EACH ptp_det WHERE index("P",ptp_pm_code) > 0 EXCLUSIVE-LOCK,
    EACH pt_mstr WHERE ptp_part = pt_part NO-LOCK :
    /*EACH csta_hist WHERE csta_part = ptp_part NO-LOCK: /*AND abs(ptp__dec02 - csta_tax_rt ) > 0.005 NO-LOCK :*/*/
    tax_rate = - 100.
    vno = 0.
    FOR EACH pc_mstr WHERE pc_part = ptp_part NO-LOCK BREAK BY pc_list BY pc_start DESC:
       IF first-of (pc_list) THEN DO:
          vno = vno + 1.
          IF pc_list <> "S15032" THEN vend = pc_list.
          FIND FIRST ad_mstr WHERE ad_addr = pc_list NO-LOCK NO-ERROR.
          IF AVAILABLE (ad_mstr) THEN DO:
             IF tax_rate < DECIMAL(SUBSTRING(ad_tax_usage,2,3)) / 100 THEN 
                tax_rate = DECIMAL(SUBSTRING(ad_tax_usage,2,3)) / 100.
             curr = pc_cur.
          END.
       END.
    END.
    IF curr <> "RMB" AND tax_rate = 0 THEN tax_rate = 0.17.
    IF ptp__dec02 <> tax_rate AND tax_rate <> -100 THEN DO:
       ASSIGN ptp__dec02 = tax_rate. 
       /*DISP ptp_part ptp_pm_code ptp__dec01 ptp__dec02 tax_rate curr vno vend pt_desc1 WITH STREAM-IO WIDTH 200.*/
    END.
         
END.
